package com.mydemo.charging.device.controller;

import com.mydemo.charging.common.pojo.query.NearStationsQuery;
import com.mydemo.charging.common.pojo.vo.StationDetailVO;
import com.mydemo.charging.common.pojo.vo.StationInfoVO;
import com.mydemo.charging.common.protocol.JsonResult;
import com.mydemo.charging.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 站场 桩 枪接口全都集中在设备controller
 */

@Slf4j
@RestController
public class DeviceController {
    @Autowired
    private DeviceService  deviceService;

    // 查询附近充电站
    @GetMapping("/device/station/near")
    public JsonResult<List<StationInfoVO>> nearStations(NearStationsQuery query){
        return JsonResult.ok(deviceService.nearStations(query));
    }

    // 查询某个充电站详情包括站场信息以及站场关联的枪数据
    @GetMapping("/device/station/detail/{stationId}")
    public JsonResult<StationInfoVO> detailStation(@PathVariable Integer stationId){
        log.debug("查询充电站详情 入参:{}",stationId);
        StationDetailVO stationDetailVO = deviceService.detailStation(stationId);
        log.debug("查询充电站详情 入参:{},出参:{}",stationId,stationDetailVO);
        return JsonResult.ok(stationDetailVO);
    }

    // 订单调用设备检查枪是否可用
    @GetMapping("/device/gun/check")
    public JsonResult<Boolean> checkGun(@RequestParam("gunId") Integer gunId){
        return JsonResult.ok(true);
    }
}
